Electrode = Button.extend({
	runningAction:null,
	runningAction1:null,
	runningAction2:null,
	runningAction3:null,
	runningAction4:null,
	runningAction5:null,
	runningAction6:null,
	runningAction7:null,
	ctor:function(parent, zIndex, tag, callback, back){
		this._super(parent, zIndex, tag, "#equitment/electrode.png", callback, back);
		this.setTag(tag);
		this.initAction();
		this.initAction1();
		this.initNumAction();
		this.initNumAction1();
		this.initNumAction2();
		this.initNumAction3();
		this.initNumAction4();
		this.initNumAction5();
		
	},
	initAction:function(){
		var animFrames=[];
		
			for(var i=1;i<7;i++){
				var str="electrode/electrode"+i+".png";
				var frame=cc.spriteFrameCache.getSpriteFrame(str);
				animFrames.push(frame);
			}

		var animation=new cc.Animation(animFrames,0.2)
		this.runningAction=cc.repeat(cc.animate(animation),3);
		this.runningAction.retain();
	},
	//动画
	initAction1:function(){
		var animFrames=[];
		for(var i=1;i<6;i++){
			var str="electrode_1/electrode"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.2) 
		this.runningAction1=cc.repeat(cc.animate(animation),3);
		this.runningAction1.retain();
	},
	initNumAction:function(){
		var animFrames=[];
		for(var i=1;i<7;i++){
			var str="tag/num"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.5)
		this.runningAction2=cc.repeat(cc.animate(animation),1);
		this.runningAction2.retain();
	},
	initNumAction1:function(){
		var animFrames=[];
		for(var i=7;i<9;i++){
			var str="tag/num"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.5)
		this.runningAction3=cc.repeat(cc.animate(animation),1);
		this.runningAction3.retain();
	},
	initNumAction2:function(){
		var animFrames=[];
		for(var i=6;i<11;i++){
			var str="tag/num"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.5)
		this.runningAction4=cc.repeat(cc.animate(animation),1);
		this.runningAction4.retain();
	},
	
	initNumAction3:function(){
		var animFrames=[];
		for(var i=11;i<15;i++){
			var str="tag/num"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.5)
		this.runningAction5=cc.repeat(cc.animate(animation),1);
		this.runningAction5.retain();
	},
	initNumAction4:function(){
		var animFrames=[];
		for(var i=16;i<20;i++){
			var str="tag/num"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.5)
		this.runningAction6=cc.repeat(cc.animate(animation),1);
		this.runningAction6.retain();
	},
	initNumAction5:function(){
		var animFrames=[];
		for(var i=16;i<21;i++){
			var str="tag/num"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation=new cc.Animation(animFrames,0.5)
		this.runningAction7=cc.repeat(cc.animate(animation),1);
		this.runningAction7.retain();
	},


	insert:function(){
		var moveto=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*1.5));
		var moveto1=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.95));
	 	this.setSpriteFrame("electrode/electrode1.png");
		this.runAction(cc.sequence(moveto,moveto1,cc.callFunc(function(){
			var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
			var main=instrument.getChildByTag(TAG_MAIN);
			var cal=main.getChildByTag(TAG_BUTTON_CAL);
			this.setSpriteFrame("equitment/electrode_1.png");
			this.setPosition(cc.p(gg.c_width*1.19,gg.c_height*0.9));
		},this),cc.callFunc(function(){
			gg.flow.next();
		},this)));
	},
	
	//水的搅拌
	stir:function(){
		
		
		var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
		var main=instrument.getChildByTag(TAG_MAIN);				
		var num=main.getChildByTag(TAG_NUM);
		var smile=main.getChildByTag(TAG_SMILE);
		this.setSpriteFrame("electrode/electrode1.png");
		this.setPosition(cc.p(gg.c_width*1.29,gg.c_height*0.95));
		var moveto=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*1.15));
		var moveto1=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.85));
		this.runAction(cc.sequence(moveto,moveto1,cc.callFunc(function(){
			smile.setVisible(false);
		},this),cc.spawn(this.runningAction,cc.callFunc(function(){
			num.runAction(this.runningAction2);
		},this)),cc.bezierTo(1, [cc.p(gg.c_width*1.29,gg.c_height*0.95),cc.p(gg.c_width*1.35,gg.c_height),cc.p(gg.c_width*1.5,gg.c_height*1.2)]),cc.callFunc(function(){
			
			if(gg.flow.flow.action==ACTION_DO3){
				var beaker=ll.run.getChildByTag(TAG_BEAKER);
				beaker.runAction(cc.moveTo(1,cc.p(gg.width*0.9, gg.height*0.5)));
			}else{
				var beaker=ll.run.getChildByTag(TAG_BEAKER);
				beaker.setVisible(false);
			}
			if(gg.flow.flow.action==ACTION_DO9){
				var beaker=ll.run.getChildByTag(TAG_BEAKER4);
				beaker.runAction(cc.moveTo(1,cc.p(gg.width*0.9, gg.height*0.5)));
			}
			if(gg.flow.flow.action==ACTION_DO7){
				var beaker=ll.run.getChildByTag(TAG_BEAKER6);
				beaker.runAction(cc.moveTo(1,cc.p(gg.width*0.9, gg.height*0.5)));
			}
			if(gg.flow.flow.action==ACTION_DO10){
				var beaker=ll.run.getChildByTag(TAG_BEAKER5);
				beaker.runAction(cc.moveTo(1,cc.p(gg.width*0.9, gg.height*0.5)));
			}
		
		
			//else{
				//var beaker=ll.run.getChildByTag(TAG_BEAKER6);
				//beaker.setVisible(false);
			//}
		},this),cc.callFunc(function(){
			gg.flow.next();
		},this)));
		
	},
	whipping:function(){
		var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
		var main=instrument.getChildByTag(TAG_MAIN);				
		var num=main.getChildByTag(TAG_NUM);
		this.runAction(cc.sequence(cc.spawn(this.runningAction1,cc.callFunc(function() {
			num.runAction(this.runningAction3.reverse());
		},this)),cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.95)),cc.callFunc(function(){
			this.setSpriteFrame("equitment/electrode_1.png");
			this.setPosition(cc.p(gg.c_width*1.19,gg.c_height*0.9));
		},this),cc.callFunc(function(){
			
			gg.flow.next();
		},this)));
	},
	
		
	
//	//action5
//	whipping1:function(){
//		var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
//		var main=instrument.getChildByTag(TAG_MAIN);				
//		var num=main.getChildByTag(TAG_NUM);
//		this.runAction(cc.sequence(cc.spawn(this.runningAction1,cc.callFunc(function() {
//			num.runAction(this.runningAction3.reverse());
//		},this)),cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.95)),cc.callFunc(function(){
//			this.setSpriteFrame("equitment/electrode_1.png");
//			this.setPosition(cc.p(gg.c_width*1.26,gg.c_height*0.9));
//		},this),cc.callFunc(function(){
//			gg.flow.next();
//		},this)));
//	},
	//
	stir1:function(){
		var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
		var main=instrument.getChildByTag(TAG_MAIN);				
		var num=main.getChildByTag(TAG_NUM);
		this.setSpriteFrame("electrode/electrode1.png");
		this.setPosition(cc.p(gg.c_width*1.29,gg.c_height*0.95));
		var moveto=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*1.1));
		var moveto1=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.85));
		this.runAction(cc.sequence(moveto,moveto1,cc.spawn(this.runningAction,cc.callFunc(function() {
			num.runAction(this.runningAction2);
		}, this)),cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.95)),cc.callFunc(function(){
			this.setSpriteFrame("equitment/electrode_1.png");
			this.setPosition(cc.p(gg.c_width*1.19,gg.c_height*0.85));
		},this),cc.callFunc(function() {
			ll.run.clock.doing();
		}, this),cc.delayTime(4),cc.callFunc(function() {
			ll.run.clock.stop();
			ll.run.clock.time.setVisible(true);
			var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
			var main=instrument.getChildByTag(TAG_MAIN);
			var smile=main.getChildByTag(TAG_SMILE);
			var num=main.getChildByTag(TAG_NUM);
			num.setSpriteFrame("tag/num8.png");
			smile.setVisible(true);
		}, this),cc.delayTime(1),cc.callFunc(function(){
			ll.run.clock.time.setVisible(false);
			ll.run.clock.setVisible(false);
		},this),cc.callFunc(function(){
			gg.flow.next();
		},this)));
	},
	stir2:function(){
		var beaker=ll.run.getChildByTag(TAG_BEAKER1);
		var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
		var main=instrument.getChildByTag(TAG_MAIN);				
		var num=main.getChildByTag(TAG_NUM);
		this.setSpriteFrame("electrode/electrode1.png");
		this.setPosition(cc.p(gg.c_width*1.29,gg.c_height*0.95));
		var moveto=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*1.1));
		var moveto1=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.85));
		this.runAction(cc.sequence(moveto,moveto1,cc.spawn(this.runningAction,cc.callFunc(function() {
			var bubble=beaker.getChildByTag(TAG_BEAKER_BUBBLE);
			bubble.runAction(cc.fadeTo(3, 255));
		}, this),cc.callFunc(function() {
			num.runAction(this.runningAction4);
		}, this)),cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.95)),cc.callFunc(function(){
			this.setSpriteFrame("equitment/electrode_1.png");
			this.setPosition(cc.p(gg.c_width*1.19,gg.c_height*0.85));
		},this),cc.callFunc(function() {
			ll.run.clock.doing();
		}, this),cc.delayTime(4),cc.callFunc(function() {
			ll.run.clock.stop();
			ll.run.clock.time.setVisible(true);
			var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
			var main=instrument.getChildByTag(TAG_MAIN);
			var smile=main.getChildByTag(TAG_SMILE);
			var num=main.getChildByTag(TAG_NUM);
			num.setSpriteFrame("tag/num10.png");
			smile.setVisible(true);
		}, this),cc.delayTime(1),cc.callFunc(function(){
			ll.run.clock.time.setVisible(false);
			ll.run.clock.setVisible(false);
		},this),cc.callFunc(function(){
			gg.flow.next();
		},this)));
	},
	stir3:function(){
		var beaker=ll.run.getChildByTag(TAG_BEAKER4);
		var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
		var main=instrument.getChildByTag(TAG_MAIN);				
		var num=main.getChildByTag(TAG_NUM);
		this.setSpriteFrame("electrode/electrode1.png");
		this.setPosition(cc.p(gg.c_width*1.29,gg.c_height*0.95));
		var moveto=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*1.1));
		var moveto1=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.85));
		this.runAction(cc.sequence(moveto,moveto1,cc.spawn(this.runningAction,cc.callFunc(function() {
			var bubble=beaker.getChildByTag(TAG_BEAKER_BUBBLE);
			bubble.runAction(cc.fadeTo(3, 255));
		}, this),cc.callFunc(function() {
			num.runAction(this.runningAction5);
		}, this)),cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.95)),cc.callFunc(function(){
			this.setSpriteFrame("equitment/electrode_1.png");
			this.setPosition(cc.p(gg.c_width*1.19,gg.c_height*0.85));
		},this),cc.callFunc(function() {
			ll.run.clock.doing();
		
		}, this),cc.delayTime(4),cc.callFunc(function() {
			ll.run.clock.stop();
			ll.run.clock.time.setVisible(true);
			var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
			var main=instrument.getChildByTag(TAG_MAIN);
			var smile=main.getChildByTag(TAG_SMILE);
			var num=main.getChildByTag(TAG_NUM);
			num.setSpriteFrame("tag/num1.png");
		}, this),cc.delayTime(1),cc.callFunc(function(){
			ll.run.clock.time.setVisible(false);
			ll.run.clock.setVisible(false);
		},this),cc.callFunc(function(){
			gg.flow.next();
		},this)));
	},
	stir4:function(){
		var beaker=ll.run.getChildByTag(TAG_BEAKER6);
		var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
		var main=instrument.getChildByTag(TAG_MAIN);				
		var num=main.getChildByTag(TAG_NUM);
		this.setSpriteFrame("electrode/electrode1.png");
		this.setPosition(cc.p(gg.c_width*1.29,gg.c_height*0.95));
		var moveto=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*1.1));
		var moveto1=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.85));
		this.runAction(cc.sequence(moveto,moveto1,cc.spawn(this.runningAction,cc.callFunc(function() {
			var bubble=beaker.getChildByTag(TAG_BEAKER_BUBBLE);
			bubble.runAction(cc.fadeTo(3, 255));
		}, this),cc.callFunc(function() {
			num.runAction(this.runningAction6);
		}, this)),cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.95)),cc.callFunc(function(){
			this.setSpriteFrame("equitment/electrode_1.png");
			this.setPosition(cc.p(gg.c_width*1.19,gg.c_height*0.85));
		},this),cc.callFunc(function() {
			ll.run.clock.doing();
		}, this),cc.delayTime(4),cc.callFunc(function() {
			ll.run.clock.stop();
			ll.run.clock.time.setVisible(true);
			var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
			var main=instrument.getChildByTag(TAG_MAIN);
			var smile=main.getChildByTag(TAG_SMILE);
			var num=main.getChildByTag(TAG_NUM);
			num.setSpriteFrame("tag/num17.png");
			smile.setVisible(true);
		}, this),cc.delayTime(1),cc.callFunc(function(){
			ll.run.clock.time.setVisible(false);
			ll.run.clock.setVisible(false);
		},this),cc.callFunc(function(){
			gg.flow.next();
		},this)));
	},
	
	stir5:function(){
		var beaker=ll.run.getChildByTag(TAG_BEAKER2);
		var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
		var main=instrument.getChildByTag(TAG_MAIN);				
		var num=main.getChildByTag(TAG_NUM);
		this.setSpriteFrame("electrode/electrode1.png");
		this.setPosition(cc.p(gg.c_width*1.29,gg.c_height*0.95));
		var moveto=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*1.1));
		var moveto1=cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.85));
		this.runAction(cc.sequence(moveto,moveto1,cc.spawn(this.runningAction,cc.callFunc(function() {
			var bubble=beaker.getChildByTag(TAG_BEAKER_BUBBLE);
			bubble.runAction(cc.fadeTo(3, 255));
		}, this),cc.callFunc(function() {
			num.runAction(this.runningAction7);
		}, this)),cc.moveTo(1,cc.p(gg.c_width*1.29,gg.c_height*0.95)),cc.callFunc(function(){
			this.setSpriteFrame("equitment/electrode_1.png");
			this.setPosition(cc.p(gg.c_width*1.19,gg.c_height*0.85));
		},this),cc.callFunc(function() {
			ll.run.clock.doing();
		}, this),cc.delayTime(4),cc.callFunc(function() {
			ll.run.clock.stop();
			ll.run.clock.time.setVisible(true);
			var instrument=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
			var main=instrument.getChildByTag(TAG_MAIN);
			var smile=main.getChildByTag(TAG_SMILE);
			var num=main.getChildByTag(TAG_NUM);
			num.setSpriteFrame("tag/num20.png");
			smile.setVisible(true);
		}, this),cc.delayTime(1),cc.callFunc(function(){
			ll.run.clock.time.setVisible(false);
			ll.run.clock.setVisible(false);
		},this),cc.delayTime(2),cc.callFunc(function(){
			gg.flow.next();
		},this)));
	},
});		